﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Data.Linq;

namespace Incendios0_1.tools
{
    class DBControler
    {
        public static Firedata db { get; set; }

        public static void Initialize()
        {
            DebugTextWriter writer = new DebugTextWriter();
            try
            {
                db = new Firedata(ConfigurationManager.ConnectionStrings["Incendios0_1.Properties.Settings.firedataConnectionString"].ConnectionString);
            }
            catch (Exception e)
            {
                writer.Write(e.Message);
            }
            db.Log = writer;
        }

        public static ChangeConflictCollection SaveChanges()
        {
             try
            {
                db.SubmitChanges();
                return null;
            }
            catch(Exception)
            {
                db.ChangeConflicts.ResolveAll(System.Data.Linq.RefreshMode.KeepChanges);
                return db.ChangeConflicts;
            }
        }
    }
}
